/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.einstein.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Tobe
 */
@Entity
@Table(name = "proveedor")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Proveedor.findAll", query = "SELECT p FROM Proveedor p"),
    @NamedQuery(name = "Proveedor.findById", query = "SELECT p FROM Proveedor p WHERE p.id = :id"),
    @NamedQuery(name = "Proveedor.findByCedula", query = "SELECT p FROM Proveedor p WHERE p.cedula = :cedula"),
    @NamedQuery(name = "Proveedor.findByContacto", query = "SELECT p FROM Proveedor p WHERE p.contacto = :contacto"),
    @NamedQuery(name = "Proveedor.findByDireccion", query = "SELECT p FROM Proveedor p WHERE p.direccion = :direccion"),
    @NamedQuery(name = "Proveedor.findByEmail", query = "SELECT p FROM Proveedor p WHERE p.email = :email"),
    @NamedQuery(name = "Proveedor.findByLimiteCredito", query = "SELECT p FROM Proveedor p WHERE p.limiteCredito = :limiteCredito"),
    @NamedQuery(name = "Proveedor.findByNombre", query = "SELECT p FROM Proveedor p WHERE p.nombre = :nombre"),
    @NamedQuery(name = "Proveedor.findByPago", query = "SELECT p FROM Proveedor p WHERE p.pago = :pago"),
    @NamedQuery(name = "Proveedor.findByPais", query = "SELECT p FROM Proveedor p WHERE p.pais = :pais"),
    @NamedQuery(name = "Proveedor.findByPlazo", query = "SELECT p FROM Proveedor p WHERE p.plazo = :plazo"),
    @NamedQuery(name = "Proveedor.findBySaldo", query = "SELECT p FROM Proveedor p WHERE p.saldo = :saldo"),
    @NamedQuery(name = "Proveedor.findBySaldo2", query = "SELECT p FROM Proveedor p WHERE p.saldo2 = :saldo2"),
    @NamedQuery(name = "Proveedor.findBySaldoAnterior", query = "SELECT p FROM Proveedor p WHERE p.saldoAnterior = :saldoAnterior"),
    @NamedQuery(name = "Proveedor.findBySaldoAnterior2", query = "SELECT p FROM Proveedor p WHERE p.saldoAnterior2 = :saldoAnterior2"),
    @NamedQuery(name = "Proveedor.findByTelefono", query = "SELECT p FROM Proveedor p WHERE p.telefono = :telefono"),
    @NamedQuery(name = "Proveedor.findByTelefonoMovil", query = "SELECT p FROM Proveedor p WHERE p.telefonoMovil = :telefonoMovil"),
    @NamedQuery(name = "Proveedor.findByTipo", query = "SELECT p FROM Proveedor p WHERE p.tipo = :tipo"),
    @NamedQuery(name = "Proveedor.findByUltimoPago", query = "SELECT p FROM Proveedor p WHERE p.ultimoPago = :ultimoPago")})
public class Proveedor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Size(max = 255)
    @Column(name = "cedula")
    private String cedula;
    @Size(max = 255)
    @Column(name = "contacto")
    private String contacto;
    @Size(max = 255)
    @Column(name = "direccion")
    private String direccion;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 255)
    @Column(name = "email")
    private String email;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "limite_credito")
    private BigDecimal limiteCredito;
    @Size(max = 255)
    @Column(name = "nombre")
    private String nombre;
    @Column(name = "pago")
    private Integer pago;
    @Column(name = "pais")
    private Integer pais;
    @Basic(optional = false)
    @NotNull
    @Column(name = "plazo")
    private int plazo;
    @Column(name = "saldo")
    private BigDecimal saldo;
    @Column(name = "saldo2")
    private BigDecimal saldo2;
    @Column(name = "saldo_anterior")
    private BigDecimal saldoAnterior;
    @Column(name = "saldo_anterior2")
    private BigDecimal saldoAnterior2;
    @Size(max = 255)
    @Column(name = "telefono")
    private String telefono;
    @Size(max = 255)
    @Column(name = "telefono_movil")
    private String telefonoMovil;
    @Column(name = "tipo")
    private Integer tipo;
    @Column(name = "ultimo_pago")
    @Temporal(TemporalType.DATE)
    private Date ultimoPago;
    @JoinColumn(name = "compania_id", referencedColumnName = "id")
    @ManyToOne
    private Compania companiaId;
    @OneToMany(mappedBy = "ultimoProveedorId")
    private Collection<Producto> productoCollection;

    public Proveedor() {
    }

    public Proveedor(Integer id) {
        this.id = id;
    }

    public Proveedor(Integer id, int plazo) {
        this.id = id;
        this.plazo = plazo;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCedula() {
        return cedula;
    }

    public void setCedula(String cedula) {
        this.cedula = cedula;
    }

    public String getContacto() {
        return contacto;
    }

    public void setContacto(String contacto) {
        this.contacto = contacto;
    }

    public String getDireccion() {
        return direccion;
    }

    public void setDireccion(String direccion) {
        this.direccion = direccion;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public BigDecimal getLimiteCredito() {
        return limiteCredito;
    }

    public void setLimiteCredito(BigDecimal limiteCredito) {
        this.limiteCredito = limiteCredito;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Integer getPago() {
        return pago;
    }

    public void setPago(Integer pago) {
        this.pago = pago;
    }

    public Integer getPais() {
        return pais;
    }

    public void setPais(Integer pais) {
        this.pais = pais;
    }

    public int getPlazo() {
        return plazo;
    }

    public void setPlazo(int plazo) {
        this.plazo = plazo;
    }

    public BigDecimal getSaldo() {
        return saldo;
    }

    public void setSaldo(BigDecimal saldo) {
        this.saldo = saldo;
    }

    public BigDecimal getSaldo2() {
        return saldo2;
    }

    public void setSaldo2(BigDecimal saldo2) {
        this.saldo2 = saldo2;
    }

    public BigDecimal getSaldoAnterior() {
        return saldoAnterior;
    }

    public void setSaldoAnterior(BigDecimal saldoAnterior) {
        this.saldoAnterior = saldoAnterior;
    }

    public BigDecimal getSaldoAnterior2() {
        return saldoAnterior2;
    }

    public void setSaldoAnterior2(BigDecimal saldoAnterior2) {
        this.saldoAnterior2 = saldoAnterior2;
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    public String getTelefonoMovil() {
        return telefonoMovil;
    }

    public void setTelefonoMovil(String telefonoMovil) {
        this.telefonoMovil = telefonoMovil;
    }

    public Integer getTipo() {
        return tipo;
    }

    public void setTipo(Integer tipo) {
        this.tipo = tipo;
    }

    public Date getUltimoPago() {
        return ultimoPago;
    }

    public void setUltimoPago(Date ultimoPago) {
        this.ultimoPago = ultimoPago;
    }

    public Compania getCompaniaId() {
        return companiaId;
    }

    public void setCompaniaId(Compania companiaId) {
        this.companiaId = companiaId;
    }

    @XmlTransient
    public Collection<Producto> getProductoCollection() {
        return productoCollection;
    }

    public void setProductoCollection(Collection<Producto> productoCollection) {
        this.productoCollection = productoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Proveedor)) {
            return false;
        }
        Proveedor other = (Proveedor) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.tesla.domain.Proveedor[ id=" + id + " ]";
    }
    
}
